package handler

import (
	"context"
	"github.com/google/uuid"

	product "dh.com/shop/srv/product/proto/product"
)

//Product
type Product struct{}

//NewProduct
func NewProduct() *Product {
	return &Product{}
}

var (
	_products []*product.TProduct
)

//Add
func (p *Product) Add(_ context.Context, req *product.AddMessage, _ *product.AddResponse) error {
	req.Product.Id = uuid.New().String()
	_products = append(_products, req.Product)
	return nil
}

//FindAll
func (p *Product) FindAll(_ context.Context, _ *product.FindAllRequest, rsp *product.FindAllResponse) error {
	rsp.Products = _products
	return nil
}
